package com.jiajia.study.nio.chapter01;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.StandardCharsets;

public class TestNio9 {

    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.allocate(10);
        byteBuffer.put("孙悟空".getBytes());

        byteBuffer.flip();
        // 自动解析出一个字符
        CharBuffer decode = StandardCharsets.UTF_8.decode(byteBuffer);
        while (decode.hasRemaining()) {
            System.out.println(decode.get());
        }
//        System.out.println(decode.toString());

    }
}
